package com.wenson.behavior.state;

/**
 * @ClassName: TrafficLight
 * @Author: luowangcheng
 * @Date: 2024/6/15 20:36
 * @Description:
 */
public class TrafficLight {
    //初始状态是红灯
    State state = new Red();

    public void setState(State state) {
        this.state = state;
    }

    public void switchToGreen() {
        state.switchToGreen(this);
    }

    public void switchToYellow() {
        state.switchToYellow(this);
    }

    public void switchToRed() {
        state.switchToRed(this);
    }
}
